package com.ilink.groundservice.mapper.innovationPlaza;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ilink.groundservice.entity.PO.innovationPlaza.UserLike;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserLikeMapper extends BaseMapper<UserLike> {
    //搜索用户是否点赞过该项目
    @Select("SELECT COUNT(*) FROM innovation_user_like WHERE project_id = #{projectId} AND user_id = #{userId}")
    int countUserLike(Long projectId, String userId);


    @Insert("INSERT INTO innovation_user_like (project_id, user_id) VALUES (#{projectId}, #{userId})")
    void insertUserLike(Long projectId, String userId);

    @Delete("DELETE FROM innovation_user_like WHERE project_id = #{projectId} AND user_id = #{userId}")
    void deleteUserLike(Long projectId, String userId);

    @Select("SELECT COUNT(*) FROM innovation_user_collection WHERE project_id = #{projectId} AND user_id = #{userId}")
    int countUserCollect(Long projectId, String userId);

    @Insert("INSERT INTO innovation_user_collection (project_id, user_id) VALUES (#{projectId}, #{userId})")
    void insertUserCollect(Long projectId, String userId);

    @Delete("DELETE FROM innovation_user_collection WHERE project_id = #{projectId} AND user_id = #{userId}")
    void deleteUserCollect(Long projectId, String userId);
}
